package com.gopay.solution.dao.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.solution.domain.po.SsProdLineTransDtl;

/**
 * 方案服务 产品线交易方案明细
 * @SsAcctGainDtlDAOImpl.java
 * @author liujy
 * @2013-3-26 上午11:05:44  www.gopay.com.cn Inc.All rights reserved.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Repository("ssProdLineTransDtlDAO")
public class SsProdLineTransDtlDAOImpl extends SolutionRuleDtlDAOImpl<SsProdLineTransDtl, Serializable>{

    @Override
    public SsProdLineTransDtl getByPk(Serializable id) {
        return find(SsProdLineTransDtl.class, id);
    }

    @Override
    public List<SsProdLineTransDtl> listBySolutionId(long solutionId) {
        String hql = "from SsProdLineTransDtl where solutionId = " + solutionId;
        return findByHql(hql);
    }
    
    @Override
    public boolean delBySolutionId(long solutionId) {

        List<SsProdLineTransDtl> dtls = listBySolutionId(solutionId);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

    
    @Override
    public List<SsProdLineTransDtl> listBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        String hql = "from SsProdLineTransDtl dtl where dtl.solutionId = :SolutionId and dtl.gopayIntTxnCd = :GopayIntTxnCd";
       
        Map params = new HashMap();
        params.put("SolutionId", solutionId);
        params.put("GopayIntTxnCd", intTxnCd);
        
        return findByHql(hql, params);
    }

    @Override
    public boolean delBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        List<SsProdLineTransDtl> dtls = listBySoluIdAndIntTxnCd(solutionId, intTxnCd);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }
}
